package com.study.service.impl.rabbit.topic.config;


import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * @desc:
 * @author: panxiyi
 * @date: 2023/5/11 8:27 下午
 */

@Configuration
public class RabbitConfigTopic {

    @Bean
    public Queue topicQueue() {
        // 是否持久化 是否当前连接专用，默认false；连接关闭后，默认删除队列； 是否自动删除，默认false
        return new Queue("topic_queue", true, true, true);
    }

    @Bean
    public Queue topicQueue2() {
        return new Queue("topic_queue2", true, true, true);
    }

    @Bean
    public TopicExchange topicExchange() {
        return new TopicExchange("topicExchange");
    }

    @Bean
    public Binding bindingTopic2() {
        return BindingBuilder.bind(topicQueue()).to(topicExchange()).with("topic.*.id");
    }

    @Bean
    public Binding bindingTopic() {
        return BindingBuilder.bind(topicQueue2()).to(topicExchange()).with("topic.orders.*");
    }

}
